package com.example.demo.service.impl;

import com.example.demo.model.purchaseDetails;
import com.example.demo.repository.purchaseDetailsRepository;
import com.example.demo.service.purchaseDetailsService;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;
@Transactional
@Service
public class purchaseDetailsServiceImpl implements purchaseDetailsService {
    @Resource
    private purchaseDetailsRepository puDetailRepository;


    @Override
    public purchaseDetails findById(String id) {
        return puDetailRepository.findById(id).get();
    }

    @Override
    public List<purchaseDetails> findAll() {
        return puDetailRepository.findAll();
    }

    @Override
    public void delete(String id) {
        puDetailRepository.deleteById(id);
    }

    @Override
    public void deleteAllByPdpriceIsNull()
    {
        puDetailRepository.deleteAllByPdpriceIsNull();
    }
    @Override
    public purchaseDetails save(purchaseDetails purchaseDetails) {
        return puDetailRepository.save(purchaseDetails);
    }
}
